package com.baidu.user.service.impl;

import java.math.BigDecimal;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.baidu.user.dao.ThroughMapper;
import com.baidu.user.entity.Through;
import com.baidu.user.service.ThroughsService;

@Service
public class ThroughsServiceImpl implements ThroughsService{

	@Autowired
	private ThroughMapper throughMapper;
	
	public Map<String, Object> findThroughsByPage(Integer rows, Integer page,BigDecimal id,String sort,String order) {
		// TODO Auto-generated method stub
		if(page==null){
			page=1;
		}
		if(rows==null){
			rows=5;
		}
		Map<String, Object> map = new HashMap<String, Object>();
		map.put("start", (page-1)*rows);
		map.put("end", rows*page);
		map.put("id", id);
		map.put("sort", sort);
		map.put("order", order);
		List<Through> throughs =  throughMapper.findByPage(map);
		Integer count = throughMapper.getListCount(id);
		Map<String, Object> data = new HashMap<String, Object>();
		data.put("rows", throughs);
		data.put("total", count);
		return data;
	}

	public void save(Through through) {
		throughMapper.insert(through); 
	}

	public List<Through> findPersonageThrough(BigDecimal id) {
		// TODO Auto-generated method stub
		return throughMapper.findPersonageThrough(id);
	}

}
